<template>
  <div class="box">
      <form name="cashSubmit" method='post' id="hkbfrom" :action="fromData.reqUrl">
            <input type='hidden' name='attach' :value="fromData.attach">
            <input type='hidden' name='channel' :value="fromData.channel">
            <input type='hidden' name='commodityName' :value="fromData.commodityName">
            <input type='hidden' name='commodityNum' :value="fromData.commodityNum">
            <input type='hidden' name='innerMerchantNo' :value="fromData.innerMerchantNo">
            <input type='hidden' name='innerShopNo' :value="fromData.innerShopNo">
            <input type='hidden' name='notify_url' :value="fromData.notify_url">
            <input type='hidden' name='orderId' :value="fromData.orderId">
            <input type='hidden' name='sign' :value="fromData.sign">
            <input type='hidden' name='txnAmount' :value="fromData.txnAmount">
            <input type='hidden' name='userId' :value="fromData.userId">
            <input type='hidden' name='redirect_type' :value="fromData.redirect_type">
            <input type='hidden' name='redirect_url' :value="fromData.redirect_url">
      </form>
      <div class="hybao"></div>
  </div>
</template>
<script>
import { Radio,MessageBox } from 'mint-ui';
import {
  integralExchangeProduct,hkbOrderpay
} from "src/methods/request.js";
export default {
  data() {
    return {
      route:{},
      orderNo:"",
      productName:"",
      productType:"",
      isHkb:"",
      payType:"",
      options : "",
      fromData:""
    };
  },
  computed:{
    imgUrl(){
      return this.$store._modules.root._children.a.state
    }
  },
   created() {
    // $router 直接监听无效，尚未查明，故作深拷贝处理
    this.route = Object.assign({}, this.$route);
    //此处应该发送请求
    let orderNo = this.route.query.orderNo;

    if(orderNo){
          // from自动提交跳转汇卡宝支付页面
          hkbOrderpay({orderNo:orderNo}).then(
                  response => {
                      if(response.rspCode=="0000"){
                               this.fromData =  response.data; 
                                if(response.data.reqUrl ==undefined){
                                             WeixinJSBridge.call('closeWindow');
                                }else{
                                        setTimeout(()=>{
                                            this.pay();
                                        },100)  
                                }
                                                     
                      }else{
                           MessageBox('', response.rspMsg||'支付失败');
                      }
                  }
          ).catch(
                  error => console.log(error)
          );

    }else{
        this.$router.push({
            path:"/Myorder"
        })
    }
  },
  methods:{
    pay(){
      $("#hkbfrom").submit();
    }
  },
   watch: {
    route() {
      if (this.route.path == "/payMoneyEnd") {

      }
    }
  }
}
</script>
<style lang="less" scoped>
.hybao{
width:100%;
height:1000px;
background-color:white;
position:fixed;
top:0px;
z-index:99999999
}
</style>


